package challenge01;

import java.util.Scanner;

/**
 * @author DCSGO
 * @version 1.0
 * https://www.lanqiao.cn/problems/5127/learning/?contest_id=144
 * 针对这种可以直接暴力判断的题我们只需要
 * 尽可能的将代码写得简单明了即可
 */
public class P1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for (int i = 0; i < n; i++) {
            String in = scan.next();
            char[] cards = in.toCharArray();
            //四炸
            if(cards[0]==cards[1]&&cards[1]==cards[2]&&cards[2]==cards[3]){
                System.out.println("No");
            }else{
                if((cards[0]==cards[1]&&cards[0]==cards[2])
                        ||(cards[1]==cards[2]&&cards[1]==cards[3])
                        ||(cards[2]==cards[3]&&cards[2]==cards[0])
                        ||(cards[3]==cards[0]&&cards[3]==cards[1])){
                    System.out.println("Yes");
                }else{//不为四带一
                    System.out.println("No");
                }
            }
        }
    }
}

